<?php

/**
 * Class for viewing a checkbox input element.
 *
 * @author Ian Clarence <ian.clarence@gmail.com>
 */
class ViewCheckbox extends ViewHtmlFormElement {

    /**
     * The on value for checkboxes.
     */
    const ON_VALUE = "ON";

    /**
     * The constructor.
     *
     * @param array $fields
     */
    public function __construct(array $fields = array()) {

        $fields["tag"] = "input";
        $fields["type"] = "checkbox";

        parent::__construct($fields);

        $this->setAttribute("type", $this->getType());
        $this->setAttribute("value", self::ON_VALUE);
        if ($this->getValue() == self::ON_VALUE) {
            $this->setAttribute("checked", "checked");
        }
        
    }

}